package com.qzdsoft.erpcloud.service.basic.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.qzdsoft.erpcloud.domain.basic.BillDeocdeType;
import com.qzdsoft.erpcloud.mapper.basic.BillDeocdeTypeMapper;
import com.qzdsoft.erpcloud.service.basic.BillDeocdeTypeService;
import com.qzdsoft.erpcloud.vo.query.basic.BillDeocdeTypeInfo;
import com.qzdsoft.vo.LayTableResponse;
import com.qzdsoft.vo.Response;
import com.qzdsoft.vo.ResultEnum;

/**
 * Created by Admin
 */
@Service
public class BasicBillDeocdeTypeServiceImpl implements BillDeocdeTypeService {

    @Autowired
    private BillDeocdeTypeMapper basicBillDeocdeTypeMapper;


    @Override
    public BillDeocdeType selectById(Integer id) {
        return basicBillDeocdeTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public Response<String> saveOrUpd(BillDeocdeType basicBillDeocdeType) {
        if(null != basicBillDeocdeType.getId()){
            basicBillDeocdeTypeMapper.updateByPrimaryKey(basicBillDeocdeType);
        } else {
            basicBillDeocdeType.setCtime(new Date());
            basicBillDeocdeTypeMapper.insert(basicBillDeocdeType);
        }
        return new Response<String>(ResultEnum.SUCCESS);
    }

    @Override
    public Response<String> del(Integer id) {
        basicBillDeocdeTypeMapper.deleteByPrimaryKey(id);
        return new Response<String>(ResultEnum.SUCCESS);
    }

    @Override
    public LayTableResponse<BillDeocdeTypeInfo> selectData(String name, Integer companyId, Integer isDefault, Integer isPreinstall, Integer start, Integer pageSize) {
        PageHelper.startPage(start, pageSize);
        List<BillDeocdeTypeInfo> list = basicBillDeocdeTypeMapper.selectData(name, companyId, isDefault, isPreinstall, start, pageSize);
        return new LayTableResponse<BillDeocdeTypeInfo>(list);
    }
}
